#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021-03-26 12:01
# @Author : wxc
# @File : config.py
# @Desc : flask配置类
from redis import Redis
from datetime import timedelta
import logging


class Config(object):
    # mysql
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # redis
    SESSION_REDIS = Redis(host="10.1.1.197", port=6379, db=1, charset="utf-8")
    SECRET_KEY = "SECRET_KEY"
    SESSION_TYPE = "redis"
    SESSION_USE_SIGNER = True
    LEVEL_NAME = logging.DEBUG


# 开发环境
class DevelopConfig(Config):
    DEBUG = True
    # mysql
    SQLALCHEMY_DATABASE_URI = "mysql://root:@127.0.0.1:3306/xinwen_flask"
    # redis
    PERMANENT_SESSION_LIFETIME = timedelta(minutes=2)
    SESSION_REDIS = Redis(host="10.1.1.197", port=6379, db=1, charset="utf-8")
    LEVEL_NAME = logging.DEBUG


# 生产环境
class ProductConfig(Config):
    SQLALCHEMY_DATABASE_URI = "mysql://root:@127.0.0.1:3306/xinwen_flask"
    PERMANENT_SESSION_LIFETIME = timedelta(minutes=2)
    # SESSION_REDIS = Redis(host="10.1.1.197", port=6379, db=1,charset="utf-8")
    LEVEL_NAME = logging.ERROR


# 测试环境
class TestConfig(Config):
    SQLALCHEMY_DATABASE_URI = "mysql://root:@127.0.0.1:3306/xinwen_flask"
    PERMANENT_SESSION_LIFETIME = timedelta(minutes=2)
    # SESSION_REDIS = Redis(host="10.1.1.197", port=6379, db=1,charset="utf-8")
    LEVEL_NAME = logging.DEBUG


config_dict = {
    "develop": DevelopConfig,
    "product": ProductConfig,
    "test": TestConfig,
}
